package cn.edu.hhtc.stsystem.struts2.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.lang.StringUtils;
import org.springframework.security.util.EncryptionUtils.EncryptionException;

import cn.edu.hhtc.stsystem.service.utils.ServiceUtil;

/**
 * 自定义加密标签.
 * 
 * @author linyueqin
 * 
 */
@SuppressWarnings("deprecation")
public class Des3Tag extends BodyTagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1512553822557844213L;

	private String code = "";

	public int doStartTag() throws JspException {

		String bar = "";
		if (StringUtils.isNotBlank(code)) {
			code = code.trim();
			try {
				bar = ServiceUtil.encodeToDes3(code);
			} catch (EncryptionException e) {

			}
		}

		try {
			pageContext.getOut().write(bar);
		} catch (IOException e) {

		}
		return SKIP_BODY;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
}
